#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
void prtf(int arr[], int sz)
{
	int i = 0;
	for (i = 0; i < sz; i++)
	{
		printf("%d ", arr[i]);
	}
}
int cmp(const void* p1, const void* p2)
{
	return  *(int*) p1 -  *(int*) p2;
}
void swap( char* p1,  char* p2, size_t width)
{
	int i = 0;
	for (i = 0; i < width; i++)
	{
		char tmp = *p1;
		*p1 = *p2;
		*p2 = tmp;
		p1++;
		p2++;
	}
}
void buttf(void*base,size_t sz,size_t width,int(*cmp)(const void* p1,const void* p2))
{
	int i = 0;
	for (i = 0; i < sz; i++)
	{
		int j = 0;
		for (j = 0; j < sz - 1 - i; j++)
		{
			if (cmp((char*)base + j * width, (char*)base + (j + 1) * width) > 0)
			{
				swap((char*)base + j * width, (char*)base + (j + 1) * width, width);
			}
		}
	}
}
void test()
{
	int arr[] = { 0,21,14,36,14,22 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	buttf(arr, sz, sizeof(arr[0]), cmp);
		prtf(arr, sz);
}
int main()
{
	test();
	return 0;
}